package day01;

/**
 * @author feng
 * @Date 2021/7/18 21:54
 *    静态代理
 */
public class StaticProxyTest01 {
    public static void main(String[] args) {

       MarryCompary marry = new MarryCompary(new You());
        marry.happyMarry();
    }


}

//  定义了结婚接口
interface Marry{

    void happyMarry();

}

// 定义了真实对象
class You implements Marry{

    @Override
    public void happyMarry() {
        System.out.println("真实对象的结婚的故事");
    }
}

//定义代理对象
class MarryCompary implements Marry{
    private Marry target;

    public MarryCompary(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        before();
        this.target.happyMarry();
        after();
    }

    private void after() {
        System.out.println("结婚之后，收尾款");
    }

    private void before() {
        System.out.println("结婚之前，准备庆典！");
    }

}